import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/* Router Modules */

import addsiteRoute from './modules/addsite'
// import Enterprise from './modules/enterprise'  //企业详情
import Useraddgoods from './modules/useraddgoods' // 企业管理新增产品
import CreateContent from './modules/createcontent' // 企业管理新增产品
/** note: sub-menu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']    will control the page roles (you can set multiple roles)
    title: 'title'               the name show in sub-menu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if true, the page will no be cached(default is false)
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
    affix: true                  if true, the tag will affix in the tags-view
  }
**/
export const constantRoutes = [

  {
    path: '/login', // 超级管理源登陆
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  }

]

export default new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

export const asyncRoutes = [
  {
    path: '',
    component: Layout,
    redirect: 'home',
    meta: {
      title: 'permission',
      icon: 'lock',
      roles: ['admin']
    },
    children: [
      {
        path: 'home',
        component: () => import('@/views/home/home'),
        name: 'home',
        meta: {
          title: '首页',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      }
    ]
  },
  {
    path: '/management',
    component: Layout,
    redirect: 'business',
    meta: {
      title: '站点管理',
      icon: 'lock',
      roles: ['admin']
    },
    children: [
      {
        path: 'addenterprise',
        component: () => import('@/views/management/addenterprise'),
        name: 'home',
        meta: {
          title: '新增站点',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      },
      {
        path: 'business',
        component: () => import('@/views/management/business'),
        name: 'home',
        meta: {
          title: '站点列表',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      }
    ]
  },
  {
    path: '/datareporting',
    component: Layout,
    redirect: 'home',
    meta: {
      title: 'permission',
      icon: 'lock',
      roles: ['admin']
    },
    children: [
      {
        path: 'reporting',
        component: () => import('@/views/datareporting/reporting'),
        name: 'home',
        meta: {
          title: '站点数据上报',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      }
    ]
  },
  // contentmanagement //内容管理

  // carousel  轮播图
  // announcement 公告管理
  // advisory 电商咨询
  // policy   电商政策
  // aboutblackwater  关于黑水
  CreateContent,
  {
    path: '/contentmanagement',
    component: Layout,
    redirect: 'business',
    meta: {
      title: '内容管理',
      icon: 'lock',
      roles: ['admin']
    },
    children: [
      {
        path: 'carousel',
        component: () => import('@/views/contentmanagement/carousel'),
        name: 'carousel',
        meta: {
          title: '轮播图',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      },
      {
        path: 'announcement',
        component: () => import('@/views/contentmanagement/announcement'),
        name: 'announcement',
        meta: {
          title: '公告管理',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      },
      {
        path: 'advisory',
        component: () => import('@/views/contentmanagement/advisory'),
        name: 'advisory',
        meta: {
          title: '电商咨询',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      },
      {
        path: 'policy',
        component: () => import('@/views/contentmanagement/policy'),
        name: 'policy',
        meta: {
          title: '电商政策',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      },
      {
        path: 'aboutblackwater',
        component: () => import('@/views/contentmanagement/aboutblackwater'),
        name: 'aboutblackwater',
        meta: {
          title: '关于我们',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      }

      // {
      //   path: 'ArticleDetail',
      //   component: () => import('@/views/contentmanagement/ArticleDetail'),
      //   name: 'ArticleDetail',
      //   meta: {
      //     title: '新增模板',
      //     icon: 'dashboard',
      //     noCache: true,
      //     affix: false,
      //   }
      // }
    ]
  },
  // {
  //   path: '/documentation',
  //   component: Layout,
  //   hidden: true,// (默认 false)
  //   meta: {
  //     title: '生产流程',
  //     icon: 'lock',
  //     roles: ['admin']
  //   },
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/documentation/index'),
  //       name: 'Documentation',
  //       meta: { title: '批次管理', icon: 'documentation', noCache: true, affix: true }
  //     }
  //   ]
  // },

  /** When your routing table is too long, you can split it into small modules**/
  addsiteRoute,
  // Enterprise, //企业
  // 企业管理后台
  /*
   * userhome 企业首页
   * usergoods 企业商品管理
   * userbatch 企业批次管理
   * usergoodsinput  企业信息录入
   * useroutstock  企业出库管理
   * usercore      企业个人中心
   */
  Useraddgoods, // 新增产品
  {
    path: '/user',
    component: Layout,
    redirect: 'home',
    meta: {
      title: '生产流程',
      icon: 'lock',
      roles: ['enterprise']
    },
    children: [
      {
        path: 'usergoods/goodslist',
        component: () => import('@/views/user/usergoods/goodslist'),
        name: 'addgoods',
        meta: {
          title: '产品管理',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      },
      {
        path: 'userbatch/batchlist',
        component: () => import('@/views/user/userbatch/batchlist'),
        name: 'batchlist',
        meta: {
          title: '批次管理',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      },
      {
        path: 'usergoodsinput/addgoodsinput',
        component: () => import('@/views/user/usergoodsinput/addgoodsinput'),
        name: 'addgoodsinput',
        meta: {
          title: '信息录入',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      }
    ]
  },
  {
    path: '/user/useroutstock',
    component: Layout,
    redirect: 'home',
    meta: {
      title: '出库管理',
      icon: 'lock',
      roles: ['enterprise']
    },
    children: [
      {
        path: 'outstocklist',
        component: () => import('@/views/user/useroutstock/outstocklist'),
        name: 'home',
        meta: {
          title: '出库管理',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      }
    ]
  },
  {
    path: '/user/usercore',
    component: Layout,
    redirect: 'home',
    meta: {
      title: 'permission',
      icon: 'lock',
      roles: ['enterprise']
    },
    children: [
      {
        path: 'coreadministration',
        component: () => import('@/views/user/usercore/coreadministration'),
        name: 'home',
        meta: {
          title: '个人中心',
          icon: 'dashboard',
          noCache: true,
          affix: false
        }
      }
    ]
  }
  // coreadministration
  // AddEnterprise,
  // { path: '*', redirect: '/login', hidden: true }
]
